﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="CustomerAttribute.ascx.cs" Inherits="PayrollHR.Administration.Modules.CustomerAttributeControl" %>
<%@ Register Src="ToolTipLabelControl.ascx" TagName="ToolTipLabelControl" TagPrefix="uc1" %>
<%@ Register Src="ConfirmationBox.ascx" TagName="ConfirmationBox" TagPrefix="uc2" %>
<%@ Register Src="DatePicker.ascx" TagName="DatePicker" TagPrefix="uc3" %>
<script type="text/javascript">
    $(window).bind('load', function () {
        var cbHeader = $(".cbHeader input");
        var cbRowItem = $(".cbRowItem input");
        cbHeader.bind("click", function () {
            cbRowItem.each(function () { this.checked = cbHeader[0].checked; })
        });
        cbRowItem.bind("click", function () { if ($(this).checked == false) cbHeader[0].checked = false; });
    });
    function ClearText() {
        document.getElementById('<%=ttxDistributor.ClientID%>').value = '';
        document.getElementById('<%=txtCustomerName.ClientID%>').value = '';
        document.getElementById('<%=txtTaxCode.ClientID%>').value = '';
        document.getElementById('<%=txtMobile.ClientID%>').value = '';
    };
</script>
<div class="section-header">
    <div class="title">
        <%=GetLocaleResourceString("Admin.CustomerAttribute.ManagerCustomer")%>
    </div>
    <div class="options">
        <asp:HyperLink runat="server" Visible="False" ID="hlexport" ForeColor="#6600CC">[hlexport]</asp:HyperLink>
        <asp:Button ID="btnFilter" runat="server" Text="Filter" OnClick="btnFilter_Click"
            CssClass="adminButtonBlue" ToolTip="Filter" />
        <asp:Button ID="ExportButton" runat="server" Text="Export" OnClick="ExportButton_Click"
            CssClass="adminButtonBlue" ToolTip="Xuất ra Excel" />
        <asp:Button ID="btnConfirm" runat="server" Text="Confirm Customer" OnClick="btnConfirm_Click"
            CssClass="adminButtonBlue" ToolTip="Send to Queued And SendMail each 60s." />
        <uc2:ConfirmationBox ID="cbConfirm" runat="server" TargetControlID="btnConfirm"
            YesText="<% $PayrollResources:Admin.Common.Yes %>" NoText="<% $PayrollResources:Admin.Common.No %>"
            ConfirmText="<% $PayrollResources:Admin.Common.ConfimCustomer %>" />
        <asp:Button runat="server" Text="Delete" CssClass="adminButtonBlue" ID="btnDelete" ToolTip="Delete Mail" OnClick="btnDelete_Click" />
        <uc2:ConfirmationBox ID="cbDelete" runat="server" TargetControlID="btnDelete"
            YesText="<% $PayrollResources:Admin.Common.Yes %>" NoText="<% $PayrollResources:Admin.Common.No %>"
            ConfirmText="<% $PayrollResources:Admin.Common.AreYouSure %>" />
    </div>
</div>
<div>
    <div style="border: 1px solid #2F00FF; border-radius: 15px;">
        <table>
            <tr>
                <td class="adminTitle">
                    <uc1:ToolTipLabelControl runat="server" ID="ToolTipLabelControl2" Text="<% $PayrollResources:Admin.CustomerAttribute.Distributor.Text %>" ToolTip="<% $PayrollResources:Admin.CustomerAttribute.Distributor.ToolTip %>"
                        ToolTipImage="~/Administration/Common/ico-help.gif" />
                </td>
                <td class="adminData">
                    <asp:TextBox ID="ttxDistributor" CssClass="adminInput" BackColor="Yellow" runat="server"></asp:TextBox>
                </td>
                <td class="adminTitle">
                    <uc1:ToolTipLabelControl runat="server" ID="ToolTipLabelControl1" Text="<% $PayrollResources:Admin.CustomerAttribute.CustomerName.Text %>" ToolTip="<% $PayrollResources:Admin.CustomerAttribute.CustomerName.ToolTip %>"
                        ToolTipImage="~/Administration/Common/ico-help.gif" />
                </td>
                <td class="adminData">
                    <asp:TextBox ID="txtCustomerName" CssClass="adminInput" BackColor="Yellow" runat="server"></asp:TextBox>
                </td>
                <td class="adminTitle">
                    <uc1:ToolTipLabelControl runat="server" ID="ToolTipLabelControl3" Text="<% $PayrollResources:Admin.CustomerAttribute.TaxCode.Text %>" ToolTip="<% $PayrollResources:Admin.CustomerAttribute.TaxCode.ToolTip %>"
                        ToolTipImage="~/Administration/Common/ico-help.gif" />
                </td>
                <td class="adminData">
                    <asp:TextBox ID="txtTaxCode" CssClass="adminInput" BackColor="Yellow" runat="server"></asp:TextBox>
                </td>
                <td class="adminTitle">
                    <uc1:ToolTipLabelControl runat="server" ID="ToolTipLabelControl4" Text="<% $PayrollResources:Admin.CustomerAttribute.Mobile.Text %>" ToolTip="<% $PayrollResources:Admin.CustomerAttribute.Mobile.ToolTip %>"
                        ToolTipImage="~/Administration/Common/ico-help.gif" />
                </td>
                <td class="adminData">
                    <asp:TextBox ID="txtMobile" CssClass="adminInput" BackColor="Yellow" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="adminTitle">
                    <uc1:ToolTipLabelControl runat="server" ID="ToolTipLabelControl10" Text="Từ ngày" ToolTip="Từ ngày"
                        ToolTipImage="~/Administration/Common/ico-help.gif" />
                </td>
                <td class="adminData">
                    <uc3:DatePicker ID="FromDatePicker" CssClass="adminInput" BackColor="Yellow" runat="server" />
                </td>
                <td class="adminTitle">
                    <uc1:ToolTipLabelControl runat="server" ID="ToolTipLabelControl5" Text="Đến ngày" ToolTip="Đến ngày"
                        ToolTipImage="~/Administration/Common/ico-help.gif" />
                </td>
                <td class="adminData">
                    <uc3:DatePicker ID="ToDatePicker" CssClass="adminInput" BackColor="Yellow" runat="server" />
                </td>
                <td class="adminTitle">
                    <uc1:ToolTipLabelControl runat="server" ID="ToolTipLabelControl6" Text="<% $PayrollResources:Admin.CustomerAttribute.Confirm.Text %>" ToolTip="<% $PayrollResources:Admin.CustomerAttribute.Confirm.ToolTip %>"
                        ToolTipImage="~/Administration/Common/ico-help.gif" />
                </td>
                <td class="adminData">
                    <asp:CheckBox ID="ckConfirm" BackColor="YellowGreen" runat="server" />
                </td>

                <td class="adminTitle"></td>
                <td>
                    <a id="aCleare" href="javascript:ClearText()">Xóa Tìm Kiếm</a>
                </td>
            </tr>
            <tr>
                <td class="adminTitle">
                    <uc1:ToolTipLabelControl runat="server" ID="ToolTipLabelControl7" Text="<% $PayrollResources:Admin.CustomerAttribute.Count.Text %>" ToolTip="<% $PayrollResources:Admin.CustomerAttribute.Count.ToolTip %>"
                        ToolTipImage="~/Administration/Common/ico-help.gif" />
                </td>
                <td>
                    <asp:DropDownList ID="ddlCount" CssClass="adminInput" BackColor="Yellow" OnSelectedIndexChanged="ddlCount_SelectedIndexChanged" AutoPostBack="true" runat="server">
                        <asp:ListItem Selected="True" Text="10" Value="10"></asp:ListItem>
                        <asp:ListItem Text="20" Value="20"></asp:ListItem>
                        <asp:ListItem Text="40" Value="40"></asp:ListItem>
                        <asp:ListItem Text="60" Value="60"></asp:ListItem>
                        <asp:ListItem Text="80" Value="80"></asp:ListItem>
                        <asp:ListItem Text="100" Value="100"></asp:ListItem>
                        <asp:ListItem Text="MaxValue" Value="-1"></asp:ListItem>
                    </asp:DropDownList>
                </td>
                <td class="adminData">
                    <uc1:ToolTipLabelControl runat="server" ID="ToolTipLabelControl8" Text="<% $PayrollResources:Admin.CustomerAttribute.Remain.Text %>" ToolTip="<% $PayrollResources:Admin.CustomerAttribute.Remain.ToolTip %>"
                        ToolTipImage="~/Administration/Common/ico-help.gif" />
                </td>
                <td class="adminTitle">
                    <asp:DropDownList ID="ddlRemain" BackColor="Yellow" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlRemain_SelectedIndexChanged">
                        <asp:ListItem Selected="True" Text="None" Value="0"></asp:ListItem>
                        <asp:ListItem Text="10 Ngày" Value="10"></asp:ListItem>
                        <asp:ListItem Text="20 Ngày" Value="20"></asp:ListItem>
                        <asp:ListItem Text="25 Ngày" Value="25"></asp:ListItem>
                        <asp:ListItem Text="30 Ngày" Value="30"></asp:ListItem>
                    </asp:DropDownList>
                </td>
                <td class="adminData">
                    <uc1:ToolTipLabelControl runat="server" ID="ToolTipLabelControl9" Text="<% $PayrollResources:Admin.CustomerAttribute.Alert.Text %>" ToolTip="<% $PayrollResources:Admin.CustomerAttribute.Alert.ToolTip %>"
                        ToolTipImage="~/Administration/Common/ico-help.gif" />
                </td>
                <td class="adminTitle">
                    <asp:DropDownList ID="ddlAlert" BackColor="Red" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlAlert_SelectedIndexChanged">
                        <asp:ListItem Selected="True" Text="10 Ngày" Value="10"></asp:ListItem>
                        <asp:ListItem Text="20 Ngày" Value="20"></asp:ListItem>
                        <asp:ListItem Text="25 Ngày" Value="25"></asp:ListItem>
                        <asp:ListItem Text="30 Ngày" Value="30"></asp:ListItem>
                        <asp:ListItem Text="365 Ngày" Value="365"></asp:ListItem>
                    </asp:DropDownList>
                </td>
            </tr>
        </table>
    </div>
</div>
<p></p>
<div>
    <asp:GridView ID="gvCustomer" runat="server" ForeColor="#333333" GridLines="None" AutoGenerateColumns="False" Width="100%" DataKeyNames="ResultsId" AllowPaging="True" PageSize="20"
        OnPageIndexChanging="gvCustomer_PageIndexChanging" OnRowDataBound="gvCustomer_RowDataBound" OnRowEditing="gvCustomer_RowEditing" OnRowUpdating="gvCustomer_RowUpdating" OnRowCancelingEdit="gvCustomer_RowCancelingEdit">
        <RowStyle BorderStyle="None" />
        <Columns>
            <asp:TemplateField ItemStyle-Width="0.5%" ItemStyle-HorizontalAlign="Center">
                <HeaderTemplate>
                    <asp:CheckBox ID="cbSelectAll" runat="server" CssClass="cbHeader" />
                </HeaderTemplate>
                <ItemTemplate>
                    <asp:CheckBox ID="cbResultsId" runat="server" CssClass="cbRowItem" ToolTip="<% $PayrollResources:Admin.Customers.Result.ToolTip %>" />
                    <asp:HiddenField ID="hfAlert" runat="server" Value='<%# Eval("Alert") %>' />
                    <asp:HiddenField ID="hdfPackageCode" runat="server" Value='<%# Eval("PackageCode") %>' />
                </ItemTemplate>
                <ItemStyle HorizontalAlign="Center" Width="0.5%" />
            </asp:TemplateField>
            <asp:TemplateField ItemStyle-Width="4%" HeaderText="N.PP">
                <ItemTemplate>
                    <asp:Label runat="server" ID="lblDistributor" Text='<%#Eval("Distributor") %>'></asp:Label>
                </ItemTemplate>
                <ItemStyle HorizontalAlign="Left" Width="4%" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Khách hàng" ItemStyle-Width="10%">
                <ItemTemplate>
                    <asp:TextBox ID="txtCustomerName" runat="server" ReadOnly="true" TextMode="MultiLine" Width="98%" Text='<%# Eval("CustomerName") %>'></asp:TextBox>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:TextBox ID="txtCustomerName" runat="server" BackColor="Yellow" TextMode="MultiLine" Width="98%" Text='<%# Eval("CustomerName") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemStyle Width="10%" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Mã số thuế" ItemStyle-Width="3%">
                <ItemTemplate>
                    <asp:Label runat="server" ID="lblTaxCode" Text='<%#Eval("Taxcode") %>'></asp:Label>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:TextBox ID="txtTaxCode" runat="server" BackColor="Yellow" TextMode="MultiLine" Width="98%" Text='<%# Eval("TaxCode") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemStyle Width="3%" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Địa chỉ" ItemStyle-Width="6%">
                <ItemTemplate>
                    <asp:Label runat="server" ID="lblAddress" Text='<%#Eval("Address") %>'></asp:Label>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:TextBox ID="txtAddress" runat="server" BackColor="Yellow" TextMode="MultiLine" Width="98%" Text='<%# Eval("Address") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemStyle Width="10%" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Điện thoại" ItemStyle-Width="4%">
                <ItemTemplate>
                    <asp:Label runat="server" ID="lblMobile" Text='<%#Eval("Mobile") %>'></asp:Label>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:TextBox ID="txtMobile" runat="server" BackColor="Yellow" TextMode="MultiLine" Width="98%" Text='<%# Eval("Mobile") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemStyle HorizontalAlign="Center" Width="4%" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Ngày bắt đầu" ItemStyle-Width="4%">
                <ItemTemplate>
                    <asp:Label runat="server" ID="lblDatePurchase" Text='<%#Eval("DatePurchase") %>'></asp:Label>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:TextBox ID="txtDatePurchase" runat="server" BackColor="Yellow" ToolTip="dd/MM/yyyy" TextMode="MultiLine" Width="98%" Text='<%# Eval("DatePurchase") %>'></asp:TextBox>
                    <asp:RegularExpressionValidator ID="regexpName" runat="server" Display="Dynamic" ForeColor="Red" ValidationGroup ="date"    
                                ErrorMessage="Phải nhập ngày theo dinh dạng dd/MM/yyyy." 
                                ControlToValidate="txtDatePurchase"     
                                ValidationExpression="^(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\d\d$" />
                </EditItemTemplate>
                <ItemStyle HorizontalAlign="Center" Width="4%" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Ngày kết thúc" ItemStyle-Width="4%">
                <ItemTemplate>
                    <asp:Label runat="server" ID="lblEndDate" Text='<%#Eval("EndDate") %>'></asp:Label>
                </ItemTemplate>
                <ItemStyle HorizontalAlign="Center" Width="4%" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Gói cước" ItemStyle-Width="4%">
                <ItemTemplate>
                    <asp:Label runat="server" ID="lblPackageCode" Text='<%#Eval("PackageCode") %>'></asp:Label>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:DropDownList ID="ddlPackageCode" BackColor="Yellow" runat="server"></asp:DropDownList>
                </EditItemTemplate>
                <ItemStyle Width="4%" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Thời hạn" ItemStyle-Width="4%">
                <ItemTemplate>
                    <asp:Label runat="server" ID="lblPackageTimeName" Text='<%#Eval("PackageTimeName") %>'></asp:Label>
                </ItemTemplate>
                <ItemStyle Width="4%" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Loại cước" ItemStyle-Width="4%">
                <ItemTemplate>
                    <asp:Label runat="server" ID="lblPackageTypeName" Text='<%#Eval("PackageTypeName") %>'></asp:Label>
                </ItemTemplate>
                <ItemStyle Width="4%" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Edit" ShowHeader="false" HeaderStyle-HorizontalAlign="Center" ItemStyle-Width="2%" ItemStyle-HorizontalAlign="Left">
                <ItemTemplate>
                    <asp:LinkButton ID="btnedit" runat="server"
                        CommandName="Edit" Text="Edit"></asp:LinkButton>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:LinkButton ID="btnupdate" runat="server" ValidationGroup="date"
                        CommandName="Update" Text="Update"></asp:LinkButton>
                    <asp:LinkButton ID="btncancel" runat="server"
                        CommandName="Cancel" Text="Cancel"></asp:LinkButton>
                </EditItemTemplate>
                <ItemStyle HorizontalAlign="Center" Width="2%"></ItemStyle>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
</div>
